# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: György Balló <ballogy@freestart.hu>

pkgbase=gssdp
pkgname=(
  gssdp
  gssdp-docs
)
pkgver=1.6.3
pkgrel=1
pkgdesc="GObject-based API for handling resource discovery and announcement over SSDP"
url="https://wiki.gnome.org/Projects/GUPnP"
arch=(loong64 x86_64)
license=(LGPL)
depends=(
  glib2
  libsoup3
)
makedepends=(
  gi-docgen
  git
  gobject-introspection
  gtk4
  meson
  pandoc
  vala
)
_commit=28c388aa45698dcc09ba24e8de849653e9eedf8c  # tags/gssdp-1.6.3^0
source=("git+https://gitlab.gnome.org/GNOME/gssdp.git#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd gssdp
  git describe --tags | sed 's/^gssdp-//;s/[^-]*-g/r&/;s/-/+/g'
}

prepare() {
  cd gssdp
}

build() {
  local meson_options=(
    -D gtk_doc=true
    -D manpages=false
  )

  arch-meson gssdp build "${meson_options[@]}"
  meson compile -C build
}

check() {
  meson test -C build --print-errorlogs
}

_pick() {
  local p="$1" f d; shift
  for f; do
    d="$srcdir/$p/${f#$pkgdir/}"
    mkdir -p "$(dirname "$d")"
    mv "$f" "$d"
    rmdir -p --ignore-fail-on-non-empty "$(dirname "$f")"
  done
}

package_gssdp() {
  depends+=(
    libg{lib,object,io}-2.0.so
    libsoup-3.0.so
  )
  optdepends=('gtk4: gssdp-device-sniffer')
  provides=(libgssdp-1.6.so)

  meson install -C build --destdir "$pkgdir"

  cd "$pkgdir"
  _pick docs usr/share/doc
}

package_gssdp-docs() {
  pkgdesc+=" (documentation)"
  depends=()
  mv docs/* "$pkgdir"
}

# vim:set sw=2 sts=-1 et:
